package com.woniuxy.service.impl;

import com.woniuxy.dao.LoginDao;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.entity.User;
import com.woniuxy.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 罗蔚
 * @Date 2022/4/4 14:10
 * @Description TODO
 */
@Service
public class LoginServiceImpl implements LoginService {
    @Autowired
    LoginDao loginDao;

    @Override
    public User login(User user) {
        //通过user的username查找password
        String username = user.getUsername();

        User _user = loginDao.findByUsername(username);
        System.out.println(_user);


        return _user;
    }

    @Override
    public ResponseEntity show() {
        List<User> list = loginDao.findAll();
        if (list == null) {
            return ResponseEntity.FAIL;
        } else {
            return new ResponseEntity(200, "查询成功", list);
        }
    }
}
